/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package film.modeles.entity;


import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.Size;
import client.modeles.entity.Client;

/**
 *
 * @author MAZID
 */
@Entity
public class Commentaire implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CommentairePK commentairePK;
    //large object 
    @Lob
    @Size(max = 65535)
    @Column(name = "contenu", length = 65535)
    private String contenu;
    private Integer note;
   
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Client client;
    
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Film film;

    public Commentaire() {
    }

    public Commentaire(CommentairePK commentairePK) {
        this.commentairePK = commentairePK;
    }

    public Commentaire(int idFilm, String loginCl) {
        this.commentairePK = new CommentairePK(idFilm, loginCl);
    }

    public CommentairePK getCommentairePK() {
        return commentairePK;
    }

    public void setCommentairePK(CommentairePK commentairePK) {
        this.commentairePK = commentairePK;
    }

    public String getContenu() {
        return contenu;
    }

    public void setContenu(String contenu) {
        this.contenu = contenu;
    }

    public Integer getNote() {
        return note;
    }

    public void setNote(Integer note) {
        this.note = note;
    }

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    public Film getFilm() {
        return film;
    }

    public void setFilm(Film film) {
        this.film = film;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (commentairePK != null ? commentairePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Commentaire)) {
            return false;
        }
        Commentaire other = (Commentaire) object;
        if ((this.commentairePK == null && other.commentairePK != null) || (this.commentairePK != null && !this.commentairePK.equals(other.commentairePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "film.modeles.entity.Commentaire[ commentairePK=" + commentairePK + " ]";
    }
    
}
